﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Activation;
using System.Text;
using Backup.Services.Entities;
using Backup.Services.Logic;
using Backup.Services.Logic.Authentification;

namespace BackupWebRole.Services
{
    [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
    public class TagWebService : ITagWebService
    {
        private TagServiceLogic _tagServiceLogic;

        public TagWebService()
        {
            _tagServiceLogic = new TagServiceLogic();
        }

        public TagEntity Save(TagEntity tagEntity, Credentials credentials)
        {
            AuthentificationHelper.AuthentificateUser(credentials);
            return _tagServiceLogic.Save(tagEntity);
        }

        public void Delete(Guid id, Credentials credentials)
        {
            AuthentificationHelper.AuthentificateUser(credentials);
            _tagServiceLogic.Delete(id);
        }

        public TagEntity Load(Guid id, Credentials credentials)
        {
            AuthentificationHelper.AuthentificateUser(credentials);
            return _tagServiceLogic.Load(id);
        }

        public List<TagEntity> LoadAll(Credentials credentials)
        {
            AuthentificationHelper.AuthentificateUser(credentials);
            return _tagServiceLogic.LoadAll();
        }

        public List<TagEntity> LoadAllByIds(List<Guid> ids, Credentials credentials)
        {
            AuthentificationHelper.AuthentificateUser(credentials);
            return _tagServiceLogic.LoadAllByIds(ids);
        }

        public List<TagEntity> GetChildrens(TagEntity tag, Credentials credentials)
        {
            AuthentificationHelper.AuthentificateUser(credentials);
            return _tagServiceLogic.GetChildrens(tag);
        }

        public TagEntity GetParent(TagEntity tag, Credentials credentials)
        {
            AuthentificationHelper.AuthentificateUser(credentials);
            return _tagServiceLogic.GetParent(tag);
        }
    }
}
